package com.oneby.service.impl;

import com.oneby.domain.Account;
import com.oneby.mapper.AccountMapper;
import com.oneby.service.AccountService;
import com.oneby.util.MyBatisUtils;
import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName AccountServiceImpl
 * @Description TODO
 * @Author Oneby
 * @Date 2021/4/2 22:43
 * @Version 1.0
 */
@Service("accountService")
public class AccountServiceImpl implements AccountService {

    public void save(Account account) {
        SqlSession sqlSession = MyBatisUtils.openSession();
        AccountMapper accountMapper = sqlSession.getMapper(AccountMapper.class);
        accountMapper.save(account);
        sqlSession.commit();
        sqlSession.close();
    }

    public List<Account> findAll() {
        SqlSession sqlSession = MyBatisUtils.openSession();
        AccountMapper accountMapper = sqlSession.getMapper(AccountMapper.class);
        List<Account> all = accountMapper.findAll();
        sqlSession.close();
        return all;
    }
    
}